import type { RouteRecordNameGeneric, RouteMeta, RouteRecordRaw } from 'vue-router'
import { defineComponent } from 'vue'
import type { MenuOption } from 'naive-ui'

export type Component<T extends any = any> =
  | ReturnType<typeof defineComponent>
  | (() => Promise<typeof import('*.vue')>)
  | (() => Promise<T>)

export interface RouteItem extends Omit<RouteRecordRaw, 'meta'> {
  path: string
  name: NonNullable<RouteRecordNameGeneric>
  meta?: Meta
  isHidden?: boolean
  children: RouteItem[]
  component?: Component
  props?: TRecord<any>
  fullPath?: string
  redirect?: string
}

export type MenuItem = MenuOption & {
  path: string
  meta?: Meta
  order?: number
  redirect?: string
}

export type Meta = RouteMeta & {
  activeMenu?: string
  // 名称
  title?: string
  // 是否忽略权限
  requireAuth?: boolean
  permissions?: string[]
  // 是否不缓存
  keepAlive?: boolean
  // tab上的图标
  icon?: string
  customIcon?: string
  order?: number
}

export type TagItem = {
  path: string
  name: NonNullable<RouteRecordNameGeneric>
  title?: string
  customIcon?: string
  icon?: string
}
